const Shell = require('shelljs');
let localPath = '../test/demo';

Shell.rm('-rf', 'dist');
Shell.rm('-rf', `${localPath}/dist`);

if (Shell.exec('npm run build').code !== 0) {
    console.log('\x1B[31m%s\x1B[0m', '缺少permanent文件');
    setTimeout(() => {
        console.log('\x1B[36m%s\x1B[0m', '开始打包permanent文件');
        Shell.exec('npm run permanent');
        Shell.exec('npm run build');
    }, 500);
}

Shell.cp('-r', './permanent', localPath);
Shell.cp('-r', './dist', localPath);

console.log('\x1B[36m%s\x1B[0m', '部署完成');
